from login.page import page_get
import ddddocr

# 识别验证码
def get_captcha(screenshot_path):
    ocr = ddddocr.DdddOcr()
    with open(screenshot_path, 'rb') as f:
        img_bytes = f.read()
    result = ocr.classification(img_bytes)
    return result

def login_ERP(username,password):
    page =  page_get()
    page.get("http://192.168.16.240:8001/rebotlogin")
    page('@placeholder=请输入账号').input(username)
    page('@placeholder=请输入密码').input(password)
    page("t:img").save(r"..\imgs", rename='imgs.png')
    result = get_captcha(r"..\imgs\imgs.png")
    page('@placeholder=验证码').input(result)
    page(".el-button el-button--primary el-button--mini is-round").click()


# login_ERP("zhanhuawei","weiwei666")